<include file="Public/header1" title="直播管理" />
<style type="text/css">
    .more .panel{display: none}
</style>

<div class="main">
    <div class="wrap">
        <include file="Public/sidebar" active="专题管理" />
        <div class="content">
            <div class="nav">
                <div class="nav-menu">
                    <form id="search-form" action="{:U('index')}">
                        <div class="date-choose" style="padding: 0;">
                            <div class="date-item">
                                <div class='input-group date' id='datetimepicker1'>
                                    <input type='text' class="form-control" name="s_time" value="{$Think.get.s_time}" />
                                <span class="input-group-addon">
                                <span class="glyphicon glyphicon-calendar"></span>
                            </span>
                                </div>
                            </div>
                            <span class="date-text">至</span>
                            <div class="date-item">
                                <div class='input-group date' id='datetimepicker2'>
                                    <input type='text' class="form-control" name="e_time" value="{$Think.get.e_time}" />
                                <span class="input-group-addon">
                                <span class="glyphicon glyphicon-calendar"></span>
                            </span>
                                </div>
                            </div>
                        </div>
                        <div class="search" style="width: 302px;">
                            <input type="text" class="search-inner" name="title" value="{$Think.get.title}" style="width: 246px; height: 31px;">
                            <div class="search-icon" id="search-btn">
                                <i></i>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
            <table class="topics">
                <thead>
                <tr>
                    <th class="c-title"></th>

                    <th>预览图</th>
                    <th>标题</th>
                    <th>开始时间</th>
                    <th>状态</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody>
                <foreach name="liveList" item="val">
                    <tr>
                        <td class="c-title"><input name="gid" type="checkbox" value="{$val.group_id}" class="np" /></td>
                        <td class="topic-img">
                            <img width="100%" height="55" src="{$val.image_url|default='http://jianwei.appwuhan.net/Public/images/defaultpic.gif'}" alt="">
                        </td>
                        <td class="c-content">
                            <a href="{:U('Live/liveinfo')}?group_id={$val.group_id}">{$val.title}</a>
                        </td>
                        <td>
                            {$val.start_time|date="Y-m-d H:i",###}
                        </td>
                        <td>
                            <switch name="val.v_status">
                                <case value="-1"><span style='color:#ccc'>草稿</span></case>
                                <case value="0"><span style='color:blue'>待审核</span></case>
                                <case value="1"><span style='color:green'>通过</span></case>
                                <case value="2"><span style='color:gray'>审核中</span></case>
                                <case value="3"><span style='color:red'>打回</span></case>
                            </switch>
                        </td>

                        <td class="more">
                            <div class="panel">
                                <ul class="ctrl">
                                    <?php if((session('is_admin') == 1) || (session('is_type') == 1)) { ?>
                                    <switch name="val.v_status">
                                        <case value="-1">
                                            <li><a href="{:U('verify')}?id={$val.group_id}&state=1">通过</a></li>
                                            <li><a href="{:U('verify')}?id={$val.group_id}&state=3">打回</a></li>
                                        </case>
                                        <case value="0">
                                            <li><a href="{:U('verify')}?id={$val.group_id}&state=1">通过</a></li>
                                            <li><a href="{:U('verify')}?id={$val.group_id}&state=3">打回</a></li>
                                        </case>
                                        <case value="1">
                                            <li><a href="{:U('verify')}?id={$val.group_id}&state=3">打回</a></li>
                                        </case>
                                        <case value="2">
                                            <li><a href="{:U('verify')}?id={$val.group_id}&state=1">通过</a></li>
                                            <li><a href="{:U('verify')}?id={$val.group_id}&state=3">打回</a></li>
                                        </case>
                                        <case value="3">
                                            <li><a href="{:U('verify')}?id={$val.group_id}&state=1">通过</a></li>
                                        </case>
                                    </switch>
                                    <?php } ?>
                                </ul>
                                <div class="close"></div>
                            </div>
                        </td>

                    </tr>
                </foreach>
                </tbody>
            </table>
            <div class="menu">

                <div class="checkAll pull-left"><input type="checkbox" id="checkAll"/></div>
                <div class="submenu pull-left">
                    <a class="btn" id="pass">通过</a>
                </div>

            </div>
            <div class="controls">
                <div id="test" classs="pagers">
                    {$showpage}
                </div>
            </div>
        </div>
    </div>
</div>
<script>

    $('#pass').click(function () {
        var id=$('[name=gid]:checked').map(function(){
            return $(this).val();
        }).get().join()
        $('.overlay').removeClass('hidden');
        $.ajax({
            type: 'POST',
            url: '{:U("verify")}?state=1',
            data: {"id":id},
            async: true,
            success: function (data) {
                $('.overlay').addClass('hidden');
                if(data.status == 1) {
                    alert(data.info);
                       window.location.reload();
                } else {
                    alert('操作失败');
                }
            }
        });

    });



    $('.delLive').click(function(){
        if(confirm('是否确定删除此直播？')){
            var obj=this;
            $.get('{:U("ajaxDelLive")}?id='+$(obj).data('gid'),function(data){
                if(data.status==1){
                    $(obj).parents('tr').remove();
                }
            })
        }
    })

    $('#delLiveAll').click(function(){
        if(confirm('是否确定删除？')){
            var id=$('[name=gid]:checked').map(function(){
                return $(this).val();
            }).get().join()

            $.get('{:U("ajaxDelLive")}?id='+id,function(data){
                if(data.status==1){
                    $('[name=gid]:checked').parents('tr').remove();
                }
            })
        }
    })

    $(function(){
        $("#checkAll").click(function(){
            debugger;
            if($(this).is(":checked")){
                $(".topics").find('input').prop("checked",true);
            }else{
                $(".topics").find('input').prop("checked",false);
            }
        });

        $(".topic-title").ellipsis({
            row: 2
        });
        $(".topic-content").ellipsis({
            row: 2
        });

        //添加按钮
        $(".add").click(function () {
            $("#vote-edit").show().addClass('on');
            $("#mask").show();
        });

        //取消编辑
        $("#mask,.newvote-footer .cancel").click(function () {
            $("#vote-edit").removeClass('on');
            $("#mask").hide();
            //删除输入框内容
            $(".vote-describe input").val("");
        });

        // 时间控件  HH:mm
        $('#datetimepicker1').datetimepicker({
            format: "YYYY-MM-DD"
        });
        $('#datetimepicker2').datetimepicker({
            format: "YYYY-MM-DD",
            useCurrent: false //Important! See issue #1075
        });
        $("#datetimepicker1").on("dp.change", function (e) {
            $('#datetimepicker2').data("DateTimePicker").minDate(e.date);
        });
        $("#datetimepicker2").on("dp.change", function (e) {
            $('#datetimepicker1').data("DateTimePicker").maxDate(e.date);
        });


        $('#search-btn').click(function () {
            $("#search-form").submit();
        });

        $('#recall').click(function(){
            if(confirm('是否确定删除？')){
                var id=$('[name=id]:checked').map(function(){
                    return $(this).val();
                }).get().join()

                $.post('{:U("reCall")}',{"id":id},function(data){
                    if(data.status==1){
                        $('[name=id]:checked').parents('tr').remove();
                    }
                })
            }
        });

        $(".more").click(function(e){
//            e.preventDefault();
//            e.stopPropagation();
            $(".panel").removeClass("active");
            $(this).find(".panel").addClass("active").show();
            $(".close").click(function (ev) {
                ev.preventDefault();
                ev.stopPropagation();
                $(this).closest(".panel").removeClass("active").hide();
            })
        })

    })
</script>
</body>
</html>